package org.finesys.chat.core.base.embedding.filter.compairson;

import java.util.UUID;

public class TypeChecker {


    static void ensureTypesAreCompatible(Object actualValue, Object comparisonValue, String key) {
        if (!(actualValue instanceof Number) || !(comparisonValue instanceof Number)) {
            if (!(actualValue instanceof String) || !(comparisonValue instanceof UUID)) {
                if (actualValue.getClass() != comparisonValue.getClass()) {
                    throw new IllegalArgumentException(String.format("Type mismatch: actual value of metadata key \"%s\" (%s) has type %s, while comparison value (%s) has type %s", key, actualValue, actualValue.getClass().getName(), comparisonValue, comparisonValue.getClass().getName()));
                }
            }
        }
    }
}
